﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;


namespace StateManager
{
    // the landing zones use a lot of the data and methods that are in the vehicle class,
    // so there's no reason to not inherit from it
    class LZone : Vechicle // i should fix that spelling
    {
        //private Rectangle colRec;
        Texture2D hasLandedTex;
        const int landOffSet = 8; // this is used so that the collision rectangle doesn't fill
        // the entire size of the landing zone, so that the player has to land close on it to win

        Color color;
        public Color ColorLanded
        {
            get
            {
                return color;
            }
            set
            {
                color = value;
            }
        }

        bool hasLanded = false;

        public Boolean HasLanded
        {
            get { return hasLanded; }
        }

        public Rectangle colRec
        {


            get
            {
                if (!hasLanded)
                    return new Rectangle((int)pos.X + landOffSet, (int)pos.Y, tex.Width - (landOffSet * 2), tex.Height);
                else
                    return Rectangle.Empty;
            
            }
        }

        public LZone(int X, int players, Level lvl)
            :this(X, lvl)
        {
            
            //pos = new Vector2((X / players) - tex.Width, 48 * 2); // since these will be at the top of the screen, y is going to be only 0
            
        }

        public LZone(int X, Level lvl)
        {
            loadContent(lvl);
            pos = new Vector2(X- tex.Width, 48 * 2);
        }
        // i need to add code stating that the thing is going to be on top

        public void landed()
        {
            hasLanded = true;
        }

        public override void Draw(SpriteBatch spriteBatch, GameTime gameTime)
        {
            spriteBatch.Draw(tex, pos, Color.White);

            if (hasLanded)
            {
                spriteBatch.Draw(hasLandedTex,pos,color);
                // this will show a frog over the landing zone when a frog has landed
            }
        }

        public override void loadContent(Level lvl)
        {
            tex = lvl.Content.Load<Texture2D>("images/lzonesmall");
            hasLandedTex = lvl.Content.Load<Texture2D>("images/frog");
        }

        public override void Update(GameTime gameTime, Rectangle viewPort)
        {
            //dunno what's done here for now
        }
    }
}
